package com.ysy.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum YesOrNoEnum {

    YES(1,"YES"),
    NO(0,"NO"),
    ;

    private Integer code;
    private String desc;

    private static Map<Integer,YesOrNoEnum> cache;

    static {
        cache = Arrays.stream(YesOrNoEnum.values()).collect(Collectors.toMap(YesOrNoEnum::getCode, e -> e));
    }

    public static YesOrNoEnum get(Integer code) {
        return cache.get(code);
    }



}
